package com.sat.pay.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PayRabbitMqConfig {
    //交换机名称
    public static final String PAY_TOPIC_EXCHANGE = "pay_topic_exchange";
    //队列名称
    public static final String PAY_QUEUE = "pay_queue";
    //声明交换机
    @Bean("payTopicExchange")
    public Exchange topicExchange(){
        return ExchangeBuilder.topicExchange(PAY_TOPIC_EXCHANGE).durable(false).build();
    }
    //声明队列
    @Bean("payTopicQueue")
    public Queue topicQueue(){
        return QueueBuilder.durable(PAY_QUEUE).build();
    }
    //声明绑定关系

    @Bean
    public Binding itemQueueExchange(
            @Qualifier("payTopicQueue")Queue queue,
            @Qualifier("payTopicExchange")Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("pay.sat.#").noargs();
    }

}
